﻿using FreeSql;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LogExtensions
{
    public class LogConfig
    {


        /// <summary>
        /// 数据库类型(默认是PostgreSQL)
        /// </summary>
        public DataType DataType { get; set; } = (DataType)2;

        /// <summary>
        /// 连接字符串
        /// </summary>
        public string ConnectionString { get; set; } = "";

        /// <summary>
        /// 使用PgCopy
        /// </summary>
        public bool UseBulk { get; set; } = true;
        /// <summary>
        /// 是否开启分表
        /// </summary>
        public bool EnableShard { get; set; }

        /// <summary>
        /// 每天4点执行分表清理
        /// </summary>
        public int ShardTableClearHour { get; set; } = 4;


        /// <summary>
        /// 分表保留天数/不分表保留天数
        /// </summary>
        public int ShardReserveTableDay { get; set; } = 1;


        /// <summary>
        /// 表名，默认为小写log
        /// </summary>
        public string TableName { get; set; } = "log";


        /// <summary>
        /// 操作日志开关
        /// </summary>
        public bool Operation { get; set; } = false;

        /// <summary>
        /// 是否开启http日志
        /// </summary>
        public bool HttpLog { get; set; } = false;


        /// <summary>
        /// CombineLogs 
        /// </summary>
        public bool CombineLogs { get; set; } = true;

        /// <summary>
        /// 默认仅记录500的http日志
        /// </summary>
        public List<StatusCode>? StatusCodes { get; set; } = new List<StatusCode>() { new StatusCode { Max = 1000, Min = 500 } };

        /// <summary>
        /// 仅显示在控制台
        /// </summary>
        public LogShows[] Shows { get; set; } = new LogShows[] { };

        /// <summary>
        /// 包括的路径
        /// </summary>
        public List<string> Includes { get; set; } = new List<string>();
        /// <summary>
        /// 不包括的路径
        /// </summary>
        public List<string> Excludes { get; set; } = new List<string>();

    }

    public class StatusCode
    {
        public int Min { get; set; }
        public int Max { get; set; }
    }
    /// <summary>
    /// 日志显示
    /// </summary>
    public enum LogShows
    {
        /// <summary>
        /// 控制台
        /// </summary>
        Console = 0,

        /// <summary>
        /// 文件
        /// </summary>
        File = 1,

        /// <summary>
        /// 数据库
        /// </summary>
        DataBase = 2
    }
}
